package com.hibase.quartz.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageInfo;
import com.hibase.core.mybatis.service.BaseServiceImpl;
import com.hibase.quartz.entity.MdsJobLog;
import com.hibase.quartz.entity.vo.MdsJobLogSearchVO;
import com.hibase.quartz.mapper.MdsJobLogMapper;
import com.hibase.quartz.service.MdsJobLogService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author liuyunlei
 * @since 2020-11-18
 */
@Service
@Transactional(readOnly = true, rollbackFor = Exception.class)
public class MdsJobLogServiceImpl extends BaseServiceImpl<MdsJobLogMapper, MdsJobLog> implements MdsJobLogService {

    /**
     * 查询列表
     */
    @Override
    public PageInfo<MdsJobLog> selectMdsJobLogList(MdsJobLogSearchVO searchVO) {

        QueryWrapper<MdsJobLog> mdsJobLogQueryWrapper = new QueryWrapper<>();

        if (StrUtil.isNotBlank(searchVO.getJobName())) {
            mdsJobLogQueryWrapper.eq("job_name", searchVO.getJobName());
        }

        return super.page(searchVO, mdsJobLogQueryWrapper.orderByDesc("id"));
    }

    /**
     * 改变记录
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void saveMdsJobLog(MdsJobLog entity) {

        super.store(entity);
    }

    /**
     * 查询详情
     */
    @Override
    public MdsJobLog viewMdsJobLog(String id) {

        MdsJobLog entity = super.getById(id, true);

        return entity;
    }

    /**
     * 删除记录
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void deleteMdsJobLog(String id) {

        super.deleteBy(id);
    }
}
